package com.vint.mi;


/**
 * 1.done
 * 2. 数7
 */
public class Mi63 {
    public static String solution(String line){
    	int t = Integer.parseInt(line);
    	int sum = 0;
    	int ret = 0;
    	for(int i=1;i<=200000;i++){
    	    if(i%7==0||String.valueOf(i).contains("7")){
    	    	continue;
	        }
		    sum++;
		    if(sum==t){
			    ret = i;
		    }
        }
        return String.valueOf(ret);
    }
    public static void main(String[] args) {
        System.out.println(solution("88888"));
        System.out.println(solution("99999"));
    }
}
